package com.example.light.redis;


public abstract class BasePrefix implements KeyPrefix {

    private int seconds;
    private String prefix;

    /**
     * 0代表永不过期
     *
     * @param prefix
     */
    public BasePrefix(String prefix) {
        this(0, prefix);
    }

    public BasePrefix(int seconds, String prefix) {
        this.seconds = seconds;
        this.prefix = prefix;
    }

    @Override
    public int expireSeconds() {
        return seconds;
    }

    @Override
    public String getPrefix() {
        String className = getClass().getSimpleName();
        return className + ":" + prefix + ":";
    }
}
